package Operation;

import Book.BookList;

import java.util.Scanner;

public class FindOpperation implements IOperation{
    @Override
    public void work(BookList booklist) {

        System.out.println("立刻查找图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要查找书的名字》");
        String name = scanner.nextLine();
        int tail = 0;
        int i = 0;
        for (i = 0; i < booklist.getUsedSize(); i++) {
            if(name.equals(booklist.getName(i))){
                tail = i;
                break;
            }
        }
        if(i==booklist.getUsedSize()){
            System.out.println("找不到这本书");
        }else{
            System.out.println("找到了！");
            System.out.println(booklist.getBook(tail));
        }
    }
    }

